/*
 *      gelogger.h
 *      
 *      Copyright 2009 Georg Sawtschuk <georg@mobila>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#include <gtk/gtk.h>


#define DEF_NOLOGTIME (20*60)
#define DEF_REP_ABSENCE_TIME (30*60)
#define DEF_LOGFILE "/work.log"

#define IDLE_SPAN 1

#define GLTRC   4
#define GLDBG   3
#define GLWRN   2
#define GLERR   1


typedef struct
{
	GtkWidget*	nologtime; 
	GtkWidget*	rep_absence_time;
	GtkWidget*	logfile;
	GtkWidget*	debug;

} t_wldlg;

typedef struct
{
	gint              x;
	gint              y;
	GdkModifierType   mask;
} t_idler;

//plugins structure
typedef struct 
{
//	XfcePanelPlugin *plugin;

	GtkWidget*      toplist; //widget with a list of last 10 logged events
	GtkWidget*      editbox; //widget where log entry is entered by user
	GtkWidget*      icon; //icon for make it easier for user get plugin menu and it flashes indicating something
	GtkWidget*      hbox; //container for other widgets
	GtkWidget*      frame; //container for other widgets


	//configurable
	int             nologtime; //seconds after that the plugin should gain user attention if he forgot to log his work
	int             rep_absence_time; /* absence time , which should be reported (seconds)*/
	gchar*          logfile; /* plain text file, where the log informationsa are stored (log file format, time + text) */
	int             debug; /* write in log some debuging infos */
	

	time_t          absence_start; //time, since the user nothing did
	time_t          work_start; //time wenn the user did some thing (moved mouse cursor, pressed any key)
	int             is_away; //flag indicating that the user's absense detected

	int             nologcounter; //counts seconds, since last user's update of the work.log
	int             iconswitcher; //0 is on, 1 is off

	guint			timeout;
	
	t_wldlg         pdlg; // propoerty dialog

	int             timeout_id;

	t_idler         idler;
	
} t_gelogger;


int         report( t_gelogger* gelogger, time_t _time, char* _message );
int         debug( int _level, t_gelogger gelogger, char* _message );
char*       get_default_logfile();
int         detect_idle( t_gelogger* gelogger );
void        gelogger_set( t_gelogger* gelogger ); 
gboolean    gelogger_check_absence( t_gelogger* gelogger );

